#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>
#include <QTimer>
#include <QThread>
#include <QSettings>
#include "plc.h"
#include "log.h"
#include "camera.h"

namespace Ui {
class MainWindow;
}



class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QString config_path, QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;


    //plc
    Plc* _plc;
    QThread* _plc_thread;

    //log
    Log* _log;
    QThread* _log_thread;

    //camera
    int _camera_count;
    QVector<CamParam> _camera_param;
    QMap<int, QThread*> _camera_threads;
    QMap<int, Camera*> _camera_workers;

    //config
    QSettings _setting;

    void LoadConfig();
    void ConfigUi();

    void Init();
    void OpenThread();
    void OpenCameras();
    void CloseCameras();

private slots:
    void ShowCamera(const int& camera_index, const QImage& img);

    void on_pushButton_clicked();
    void on_pushButton_2_clicked();

    void on_pushButton_4_clicked();

    void on_pushButton_5_clicked();

    void on_pushButton_3_clicked();

signals:
    void pause_req_vision(const bool&);
    //void update_camparam(const CamParam&);
};

#endif // MAINWINDOW_H
